.\" RCSid "$Id: total.1,v 1.10 2017/05/02 02:51:01 greg Exp $"
.TH TOTAL 1 2/3/95 RADIANCE
.SH NAME
total - sum up columns
.SH SYNOPSIS
.B total
[
.B \-m
][
.B \-sE
|
.B \-p
|
.B \-u
|
.B \-l
][
.B \-i{f|d}[N]
][
.B \-o{f|d}
][
.B "\-in M"
][
.B "\-on M"
][
.B \-tC
][
.B \-N
[
.B \-r
]]
[
file ..
]
.SH DESCRIPTION
.I Total
sums up columns of real numbers from one or more files
and prints out the result on its standard output.
.PP
By default,
.I total
computes the straigt sum of each input column, but multiplication
can be specified instead with the
.I \-p
option.
Likewise, the
.I \-u
option means find the upper limit (maximum), and
.I \-l
means find the lower limit (minimum).
.PP
Sums of powers can be computed by giving an exponent with the
.I \-s
option.
(Note that there is no space between the 
.I \-s
and the exponent.)
This exponent can be any real number, positive or negative.
The absolute value of the input is always taken before the
power is computed in order to avoid complex results.
Thus,
.I \-s1
will produce a sum of absolute values.
The default power (zero) is interpreted as a straight sum without
taking absolute values.
.PP
The
.I \-m
option can be used to compute the mean rather than the total.
For sums, the arithmetic mean is computed.
If a power is also specified using the
.I \-s
option, the inverse power will be applied to the averaged result.
For products, the geometric mean is computed.
(A logarithmic sum of absolute values is used to avoid overflow, and 
zero values are silently ignored.)
.PP
If the input data is binary, the
.I \-id
or
.I \-if
option may be given for 64-bit double or 32-bit float values, respectively.
Either option may be followed immediately by an optional
count, which defaults to 1, indicating the number of double or float
binary values to read per record on the input file.
(There can be no space between the option and this count.)\0
Similarly, the
.I \-od
and
.I \-of
options specify binary double or float output, respectively.
These options do not need a count, as this will be determined by the
number of input channels.
.PP
A count can be given as the number of lines to read before
computing a result.
Normally,
.I total
reads each file to its end before producing its result, 
but this behavior may be overridden by inserting blank lines in
the input.
For each blank input line, total produces a result as if the
end-of-file had been reached.
If two blank lines immediately follow each other, total closes
the file and proceeds to the next one (after reporting the result).
The
.I \-N
option (where N is a decimal integer) tells
.I total
to produce a result and reset the calculation after
every N input lines.
In addition, the
.I \-r
option can be specified to override reinitialization and thus
give a running total every N lines (or every blank line).
If the end of file is reached, the current total is printed
and the calculation is reset before the next file (with or without the
.I \-r
option).
.PP
The
.I \-in
option if present, will limit the number of input records read
(per input file).
The
.I \-on
option may be used to limit the total number of outut records produced.
.PP
The
.I \-tC
option can be used to specify the input and output tab character.
The default tab character is TAB.
.PP
If no files are given, the standard input is read.
.SH EXAMPLE
To compute the RMS value of colon-separated columns in a file:
.IP "" .2i
total \-t: \-m \-s2 input
.PP
To produce a running product of values from a file:
.IP "" .2i
total \-p \-1 \-r input
.SH BUGS
If the input files have varying numbers of columns, mean values
will certainly be off.
.I Total
will ignore missing column entries if the tab separator is a non-white
character, but cannot tell where a missing column should have been if
the tab character is white.
.SH AUTHOR
Greg Ward
.SH "SEE ALSO"
cnt(1), neaten(1), rcalc(1), rcollate(1), rlam(1), tabfunc(1)
